i = 0
def ackerman(m,n):
    global i
    i += 1
    if m == 0: 
        print "returning %d + 1:" % n
        return n + 1
    elif m > 0 and n == 0: 
        print "returning ackerman(%d - 1, 1):" % m
        return ackerman(m-1,1)
    elif m > 0 and n > 0: 
        print "returning ackerman(%d - 1,ackerman(%d,%d - 1)):" % (m,m,n)
        return ackerman(m-1,ackerman(m,n-1))
#print ackerman(1,0),ackerman(2,2), ackerman(3,4)
print ackerman(4,4)
print i, " recursions"
    
    